/**
 * 用户列表 add by gsh
 */
$(function() {
	$("#chkAll").change(function() {
		var chkStatus = $(this).is(":checked");
		$("[id^=chk]:not(#chkAll)").each(function() {
			this.checked = chkStatus;
		});
	});

});

function getChecked() {
	var map = $("[id^=chk]:not(#chkAll)").map(function() {
		if (this.checked)
			return this.value;
	});
	return map.get();
}

function edit(id) {
	var index = msgWnd.open({
		title : "修改商户信息",
		skin : 'layui-layer-lan',
		type : 2,
		shade : 0.5,
		area : [ "90%", "90%" ],
		maxmin : true,
		content : '/merchant/edit/' + id,
		zIndex : layer.zIndex
	});
}

function viewMerchantImg(id) {
	var index = msgWnd.open({
		title : "查看商家展示图片",
		skin : 'layui-layer-lan',
		type : 2,
		shade : 0.5,
		area : [ "800px", "520px" ],
		maxmin : true,
		content : '/merchant/images/' + id,
		zIndex : layer.zIndex
	});
}
function selDateRange() {
	var index = msgWnd.open({
		title : "选择查询日期",
		skin : 'layui-layer-lan',
		type : 2,
		shade : 0.5,
		area : [ "510px", "220px" ],
		maxmin : true,
		content : '/views/pages/ddl/ddlDateRange.jsp',
		zIndex : layer.zIndex
	});	
	msgWnd.selectResultCallBack=function(val){
		$("#exportForm").find("[name=createTime]").val(val.time1);
		$("#exportForm").find("[name=createTime1]").val(val.time2);
		$('#exportForm').submit();
	};	
}

function setRecomend(_id,defVal){
	var index = msgWnd.prompt({title: '设置推荐权重',value:defVal}, function(promptVal){
		if(isNaN(promptVal)){
			return msgTools.alert("错误", "请输入数字！", 2000);
		}
		$.ajax({
			type : "POST",
			url : "/merchant/recomend/sort",
			data:"id="+_id+"&sort="+promptVal,
			dataType : "json",
			success : function(msg) {				
				if (msg.data.status == 1) {
					msgWnd.close(index);
					msgTools.alert("设置推荐权重", "设置成功。", 1000);
					if(typeof(reloadPg)!="undefined")
						reloadPg();
					else
						window.location.href = window.location.href;
					
				} else {
					msgTools.alert("设置推荐权重", "设置失败。", 2000);
				}
			},error:function(msg){
				alert(msg.responseText);
			}
		});	    
	});
}
function viewUser(id) {
	var index = msgWnd.open({
		title : "查看用户信息",
		skin : 'layui-layer-lan',
		type : 2,
		shade : 0.5,
		area : [ "510px", "550px" ],
		maxmin : true,
		content : '/user/view/' + id,
		zIndex : layer.zIndex
	});	
}